#!/bin/bash -e

function info() {
echo Usage: `basename $0` script_name [args]
exit 65
}

test $# -lt 1 && info

# pid=$$
use=.use


while true; do


pids=`ps -o args -u $(whoami) |grep "$*"|wc -l`

echo $pids

if test $pids -gt 3; then
	echo '########################################################################################################################################################' >> $use
	echo '#'`id -u;date;pwd;hostname` >> $use


	# ps -a --ppid=$pid -o pid,ppid,uid,user,pcpu,%mem,size,vsize,start_time,etime,bsdtime,cmd >> $use
	# ps --ppid=$pid -o pid,ppid,uid,user,pcpu,%mem,size,vsize,start_time,etime,bsdtime,cmd >> $use

	ps -u`whoami` -o pid,ppid,uid,user,pcpu,%mem,size,vsize,start_time,etime,bsdtime,args >> $use

	sleep 60

else 
	break
	fi
done



